<script>
	import _function from '@/common/_function.js'
	import api from '@/common/api.js'

	export default {
		onLaunch: async function() {
			const ress = await _function.initlogin()
			if(ress.data.code==200){
				uni.setStorageSync('token', ress.data.data)
				getApp().globalData.islogin = true
				// 获取用户信息
				let userinfo = await _function.request(api.getuserinfo)
				if(userinfo.data.code==200){
					// 保存用户id
					getApp().globalData.uid = userinfo.data.data.userinfo.id
				}
			}

			const res = await _function.request(api.payprice)
			if (res.data.code == 200) {
				getApp().globalData.payprice = res.data.data
			} else {
				uni.showToast({
					title: '支付金额获取失败',
					duration: 2000,
					mask: true
				})
			}
			
			let shareimg = await _function.request(api.shareimg)
			if(shareimg.data.code==200){
				getApp().globalData.shareimg = shareimg.data.data
			}
			let sharetext = await _function.request(api.sharetext)
			if(sharetext.data.code==200){
				getApp().globalData.sharetext = sharetext.data.data
			}
			console.log('App onLaunch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		globalData: {
			userinfo: null,
			pid: null,
			payprice: null, //支付金额
			islogin: false,
			uid:0,
			shareimg:null,
			sharetext:null
		}

	}
</script>

<style>
	@font-face {
		font-family: iconfont;
		src: url('~@/static/iconfont.ttf');
	}

	.fonticon {
		font-family: iconfont;
	}

	/*每个页面公共css */
	page {
		font-size: 24rpx;
		background-color: #F8F8FF;
		height: 100%;
		
	}

	image {
		width: 100%;
		height: 100%;
	}

	.absolute {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 99;
		opacity: 0;
	}
</style>
